<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #box{
            width: 200px;
            height: 200px;
            background-color: red;

            margin: 100px auto;
        }
    </style>
</head>
<body>
    <div id="box">身高是：0</div>

    <script>
        window.addEventListener('load',()=>{
            // 1、定义变量
            let height = 0 ,time=null;
            //鼠标进入
            /*
            鼠标疯狂进入时就会出现定时器累加的情况
            解决方法：在事件中对于定时器（先清除再设置）
            */
            $('box').addEventListener('mouseenter',()=>{
                //清除
                clearInterval(time);
                //设置
                time = setInterval(function(){
                    height ++;
                    $('box').innerText = `升高是:${height}`;
                },1000)
            })
        })
        function $(id){
            return typeof id === 'string' ? document.getElementById(id) : null; 
        }
    </script>
</body>
</html>